﻿//反填采购信息

$(function () {
    fantian1();
    fantian2();
})
//反填采购消息
function fantian1() {
    // 发送AJAX请求获取数据
    console.log(localStorage.getItem("purchaseID"))
    $.ajax({
        type: "get",
        url: "/Purch/FabPurch",
        data: {
            PurchaseID: localStorage.getItem("purchaseID"),
            token: localStorage.getItem("token")
        },
        success: function (res) {
            var ter = JSON.parse(res)
            console.log(ter.data)

            $(ter.data).each(function () {
                $('#purchaseCode1').val(this.purchaseCode);
                localStorage.setItem("purchaseID", this.purchaseID)
                localStorage.setItem("purchaseCode", this.purchaseCode)
                $('#ingredientName1').val(this.ingredientName);
                $('#ingredient1').val(this.ingredientnumber);
                $('#purchaseNumber1').val(this.purchaseNumber);
                $('#purchaseDate1').val(this.createdDate);
                $('#purchaseBatch1').val(this.purchaseBatch);
              
            })

        },

    });


}
//根据产品编号显示仓库信息
function fantian2() {
    // 发送AJAX请求获取数据
    console.log(localStorage.getItem("purchaseCode"))
    $.ajax({
        type: "get",
        url: "/Purch/PurchsListIng",
        data: {
            FinishedProductNo: localStorage.getItem("purchaseCode"),
            token: localStorage.getItem("token")
        },
        success: function (res) {
            var ter = JSON.parse(res)
            console.log(ter.data)

            $(ter.data).each(function () {
                $('#inventoryNo4').val(this.finishedProductNo);
                $('#inventory4').val(this.locationCoding);
                $('#invenryNum4').val(this.inventoryNum);
                $('#produceDate4').val(this.createdDate.substring(0,10));
                $('#purchCode4').val(this.warehouseName);
                $('#ingientName4').val(this.reservoirName);

            })

        },

    });


}
//入库
window.ShowInss = function ShowInss() {
    localStorage['purchaseID1'] = localStorage.getItem("purchaseID")

    //localStorage.setItem("purchaseID", purchaseID)
    //console.log(localStorage.getItem("purchaseID"))
    location.href = '../Warehouse/InventoryAdd';
}